package com.Web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Update")
public class Update extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 设置请求参数编码
        req.setCharacterEncoding("UTF-8");
        // 设置响应数据编码
        resp.setCharacterEncoding("UTF-8");
        // 获取请求参数
        String id = req.getParameter("id");
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        String cellphone = req.getParameter("cellphone");
        String address = req.getParameter("address");
        String gender = req.getParameter("gender");
        //通过响应数据流，向浏览器发送数据
        JDBCUtils.update("Update Student set name = ?,age = ?,cellphone = ?,address = ?,gender = ? where id = ? ",name,age,cellphone,address,gender,id);
        resp.getWriter().print("信息更新成功！");
    }
}
